package com.tm.media.controller;

import com.tm.media.model.entity.MaterialEntity;
import com.tm.media.service.MaterialService;
import com.tm.media.utils.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @Author Ly
 * @Data 2023/2/23 19:11
 * @ClassName MaterialController
 */
@RestController
@RequestMapping("api/v1/media/material")
public class MaterialController {
    @Autowired
    private MaterialService materialService;
    @PostMapping("list")
    public Result list(@RequestBody MaterialEntity materialEntity){
        return materialService.listMaterial(materialEntity);
    }
    @PostMapping("upload_picture")
    public Result upload_picture( @RequestParam("file")MultipartFile file) throws IOException {
      return   materialService.upload_picture(file);
    }
    //收藏图片
    @PostMapping("collect")
    public Result collect(@RequestBody MaterialEntity materialEntity){
        return materialService.collect(materialEntity);
    }
    //删除图片
    @PostMapping("del_picture")
    public Result del_picture(@RequestBody MaterialEntity materialEntity){
        return materialService.del_picture(materialEntity);
    }

}
